home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Serious Software
/
Cherwell Scientific Demos
/
pro Fit
/
pro Fit 5.0 demo (fpu).sea
/
pro Fit 5.0 demo (fpu)
/
Functions & Programs
/
•Gadgets
/
Noise
< prev
next >
Wrap
Text File
|
1996-05-31
|
1KB
|
41 lines
{
This program adds random noise to all non-empty cells
of a data column.
To use the program, first click the button "Add" above to compile it, then
bring the desired data window to front and choose Noise from the Misc menu.
You can enter the amplitude of the noise. It can either be
absolute (enter an absolute value) or relative to the present
value in a cell (enter a relative noise in percent)
}
program Noise;
var
amplitude, r: real;
percAbs: integer; {2:percent, 1:absolute}
column, i:integer;
procedure Initialize; {set default values}
begin
amplitude := 10;
percAbs := 2;
column := 1;
end;
begin
Input('$CColumn',column,
'$Pabsolute;percent$Noise type',percAbs,
'Amplitude',amplitude);
for i := 1 to NrRows do
if DataOK(i,column) then
begin
r := amplitude * (Random * 2 - 1); {Random returns between 0 and 1}
if percAbs=2 then
data[i,column] := data[i,column]*(1 + r/100) {percent}
else
data[i,column] := data[i,column] + r; {absolute}
end;
end;